package com.tech.util;

import java.util.List;
import java.util.Map;

/**
 * 控制台打印的便捷方法
 */
public class PrintUtil {
	public static void println(List<?> list) {
		println(list,0);
	}

	public static void println(List<?> list, int blankNum) {
		String str = " ".repeat(Math.max(0, blankNum));
		System.out.println(str + "{");
		for (Object o : list) {
			System.out.println(str + "  " + o);
		}
		System.out.println(str + "}");
	}

	public static void println(Map<?, ?> map) {
		System.out.println("{");
		map.forEach((key, value) -> {
			System.out.println("  {");
			System.out.println("    key: " + key);
			if (value instanceof List)
				println((List<?>) value,4);
			else
				System.out.println("    val: " + value);
			System.out.println("  }");
		});
		System.out.println("}");
	}
}
